<template>
  <div>
      <!-- 头部导航 -->
      <div class="hearder">
        <div class="button" @click="$router.go(-1)">
        <span class="iconfont icon-fanhui"></span>
      </div>
        <div class="center">推荐歌单</div>
        <router-link tag="div" to="/search" class="right iconfont icon-sousuo"></router-link>
      </div>
        <!-- 导航按钮 -->
      <div class="navs">
        <router-link tag="div" to="/recommend" class="item">
          <span>推荐</span>
        </router-link>
        <router-link tag="div" to="/rank" class="item">
          <span>排行榜</span>
        </router-link>
        <router-link tag="div" to="/singer" class="item">
          <span>歌手</span>
        </router-link>
      </div>
    <!-- 推荐内容 -->
    <div class="contentcon">
      <ul>
        <li v-for="(item, index) in title" :key="index">
          <router-link
                tag="div"
                :to="'/rank/ranklist?id=' + item.id"
                class="img"
              >
                <img :src="item.picUrl" alt="" />
              </router-link>
          <p>{{ item.name }}</p>
          <span
            ><i class="iconfont icon-erji1"></i
            >{{ item.playCount | playCountData }}</span
          >
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getPersonalizedrcon } from "../api/recommend";
export default {
  data: function () {
    return {
      title: null,
    };
  },
  components: {
  },
  created() {
    //获取歌单数据
    getPersonalizedrcon().then((data) => {
      this.title = data.result;
    });
  },
  filters: {
    playCountData(value) {
      let w = value > 10000 ? value / 10000 : value; //万计算
      let y = w > 10000 ? parseInt(value / 10000) + "亿" : parseInt(w) + "万";
      return y;
    },
  },
};
</script>

<style lang="less">
.hearder{
  background-color: #D44439;
  color: #fff;
  height: 39px;
  line-height: 39px;
  display: flex;
  text-align: center;
   .button{
       width: 45px;
       height: 45px;
       line-height: 45px;
       text-align: center;
       font-size: 16px;
       color: white;
       span{
         font-weight: bolder;
         font-size: 20px;
       }
    }
  .left,.right{
     flex:0 0 40px;
     font-size: 18px;
  }

  .center{
    flex:1
  }
}   
.contentcon {
  margin-top: 5px;
  // .navbox {
  //   margin: 5px 50px 5px 5px;
  //   display: flex;
  //   .playall{
  //     height: 31px;
  //     line-height: 32px;
  //     font-size: 14px;
  //     text-align: center;
  //     color: red;
  //     box-shadow: 0px 0px 0px 1px #eee;
  //     border-radius: 20px;
  //     padding: 0px 5px;
  //   }
  //   span{
  //     height: 31px;
  //     line-height: 32px;
  //     font-size: 14px;
  //     color: rgb(156, 156, 156);
  //   }
  // }

  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    li {
      flex: 0 0 29%;
      position: relative;
      span {
        position: absolute;
        top: 3px;
        right: 5px;
        color: #fff;
        font-size: 10px;
      }
      i {
        font-size: 15px;
        vertical-align: middle;
      }
    }
    .img {
      min-height: 50px;
      width: 100%;
      border-radius: 3px;
      img {
        width: 100%;
        border-radius: 5px;
      }
    }
    p {
      font-size: 12px;
      color: #565658;
      line-height: 15px;
      padding: 5px;
      margin-bottom: 10px;
      height: 24px;
      overflow: hidden;
    }
  }
}
</style>